package com.ttpai.boot.lbs.dao;

import com.ttpai.boot.lbs.model.MetroPointVO;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;

import java.util.List;

@DAO
public interface MetroPointDAO {


    String ALL_CITY = "上海市,佛山市";

    @SQL("SELECT ID,CITY_NAME,NAME,LNG,LAT FROM _KAIL_METRO_POINT WHERE 1=1" +
            " #if(null!=:p.cityName && ''!=:p.cityName){ AND CITY_NAME LIKE :p.cityName}" +
            " #if(null!=:p.name && ''!=:p.name){ AND NAME=:p.name}" +
            " ORDER BY ID")
    List<MetroPointVO> selectAllMetroPoint(@SQLParam("p") MetroPointVO p);


    @SQL("INSERT INTO _KAIL_METRO_POINT (CITY_NAME,METRO_LINE_NAME,LINE_NAME,UID,IS_PRACTICAL,NAME,Y,X,LNG,LAT) VALUES (:mp.cityName,:mp.metroLineName,:mp.lineName,:mp.uid,:mp.isPractical,:mp.name,:mp.y,:mp.x,:mp.lng,:mp.lat)")
    Integer insertMetroPoint(@SQLParam("mp") MetroPointVO metroPoint);


    @SQL("UPDATE _KAIL_METRO_POINT SET " +
            " #if(null != :mp.lng){ LNG=:mp.lng, } " +
            " #if(null != :mp.lat){ LAT=:mp.lat, } " +
            " ID=ID " +
            " WHERE 1=2 " +
            " #if(null!=:mp.id ){ OR ID=:mp.id }" +
            " #if(null!=:mp.uid &&  ''!=:mp.uid){ OR UID=:mp.uid }" +
            " #if(null!=:mp.cityName &&  ''!=:mp.cityName && null!=:mp.name &&  ''!=:mp.name){ OR (CITY_NAME=:mp.cityName AND NAME=:mp.name) }")
    Integer updateMetroPoint(@SQLParam("mp") MetroPointVO metroPoint);


}
